import { ref } from 'vue'
import { defineStore } from 'pinia'
import categoryImg1 from '@/assets/uploads/品质新鲜.png'
import categoryImg2 from '@/assets/uploads/价格亲民.png'
import categoryImg3 from '@/assets/uploads/售后无忧.png'
import categoryImg4 from '@/assets/uploads/物流快捷.png'
import goodsImg1 from '@/assets/uploads/新鲜好物1.png'
import goodsImg2 from '@/assets/uploads/新鲜好物2.png'
import goodsImg3 from '@/assets/uploads/新鲜好物3.png'
import goodsImg4 from '@/assets/uploads/新鲜好物4.png'
import goodsImg5 from '@/assets/uploads/人气推荐1.png'
import goodsImg6 from '@/assets/uploads/人气推荐2.png'
import goodsImg7 from '@/assets/uploads/人气推荐3.png'
import goodsImg8 from '@/assets/uploads/人气推荐4.png'
export const useCategoryStore = defineStore('category', () => {
  // 导航列表的数据管理
  // state 导航列表数据 - 使用静态数据和本地图片
  const categoryList = ref([
    {
      id: 1,
      name: '生鲜果蔬',
      children: ['新鲜水果', '蔬菜豆品'],
      goods: [
        { id: 101, name: '进口苹果 精选红富士', desc: '新鲜脆甜', price: 29.9, picture: goodsImg1 },
        { id: 102, name: '有机蔬菜礼盒', desc: '多种时令蔬菜', price: 59.9, picture: goodsImg2 }
      ]
    },
    {
      id: 2,
      name: '肉禽蛋品',
      children: ['猪肉', '牛羊肉'],
      goods: [
        { id: 201, name: '新鲜猪肉 后腿肉', desc: '农家散养', price: 39.9, picture: goodsImg3 },
        { id: 202, name: '土鸡蛋 30枚装', desc: '农村散养土鸡蛋', price: 49.9, picture: goodsImg4 }
      ]
    },
    {
      id: 3,
      name: '海鲜水产',
      children: ['鲜活鱼类', '贝类'],
      goods: [
        { id: 301, name: '新鲜三文鱼', desc: '挪威进口', price: 89.9, picture: goodsImg5 },
        { id: 302, name: '活虾 基围虾', desc: '当日捕捞', price: 59.9, picture: goodsImg6 }
      ]
    },
    {
      id: 4,
      name: '休闲零食',
      children: ['坚果炒货', '饼干糕点'],
      goods: [
        { id: 401, name: '混合坚果礼盒', desc: '多种坚果组合', price: 69.9, picture: goodsImg7 },
        { id: 402, name: '曲奇饼干礼盒', desc: '手工制作', price: 49.9, picture: goodsImg8 }
      ]
    },
    {
      id: 5,
      name: '酒水饮料',
      children: ['白酒', '啤酒'],
      goods: [
        { id: 501, name: '精选红酒', desc: '法国波尔多', price: 199, picture: goodsImg1 },
        { id: 502, name: '进口啤酒组合', desc: '德国原装', price: 89.9, picture: goodsImg2 }
      ]
    },
    {
      id: 6,
      name: '粮油调味',
      children: ['米面粮油', '调味品'],
      goods: [
        { id: 601, name: '有机大米 5kg', desc: '东北大米', price: 59.9, picture: goodsImg3 },
        { id: 602, name: '特级橄榄油', desc: '西班牙进口', price: 129.9, picture: goodsImg4 }
      ]
    },
    {
      id: 7,
      name: '母婴用品',
      children: ['奶粉辅食', '纸尿裤'],
      goods: [
        { id: 701, name: '婴儿奶粉 1段', desc: '进口奶源', price: 299, picture: goodsImg5 },
        { id: 702, name: '纸尿裤 M码', desc: '超薄透气', price: 89.9, picture: goodsImg6 }
      ]
    },
    {
      id: 8,
      name: '个人护理',
      children: ['洗护用品', '美妆护肤'],
      goods: [
        { id: 801, name: '洗发水套装', desc: '深层滋养', price: 79.9, picture: goodsImg7 },
        { id: 802, name: '保湿面霜', desc: '天然成分', price: 129.9, picture: goodsImg8 }
      ]
    }
  ])

  // 保留原有的getCategory方法，但直接返回静态数据
  const getCategory = async () => {
    // 直接返回已有的静态数据
    return { result: categoryList.value }
  }

  return {
    categoryList,
    getCategory
  }
})
